#!/usr/bin/env bash

i=0
while read gif; do
  gifs[ $i ]="$gif"
  (( i++ ))
done < <(curl -s http://sadbastard.org/lonely-web/images/ | sed -e 's/.*href="\(.*\)">.*/\1/' | grep gif)

rando=$(( $RANDOM % ${#gifs[@]} ))

printf "http://sadbastard.org/lonely-web/images/%s\n" "${gifs[$rando]}"
